package com.webside.front.advertisement.controller;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.webside.front.common.model.AdvertisementEntity;
import com.webside.front.common.service.AdvertisementService;

@Controller
@RequestMapping(value = "/ad/")
public class advertisementController {
	@Autowired
	AdvertisementService advertisementService;
	
	@RequestMapping(value = "getad", method = { RequestMethod.GET, RequestMethod.POST })
	public @ResponseBody List<AdvertisementEntity> getAdByPosition(String positionCode){
		Date date = new Date();
		System.out.println(positionCode);
		List<AdvertisementEntity> list = advertisementService.selectAdByPosition(date, positionCode);
		System.out.println(list.size());
		return list;
	}
}
